import { http } from "@/utils/http";

type ApiResponse<T = any> = {
  code: number;
  data: T;
  message?: string;
  msg?: string;
};

type UserListResponse = {
  list: Array<any>;
  total?: number;
};

/** 获取用户端用户管理列表 */
export const getClientUserList = (data?: { username?: string }) => {
  return http.request<ApiResponse<UserListResponse>>("get", "/api/user/list", {
    params: data
  });
};

/** 创建新用户端用户 */
export const createClientUser = (data: object) => {
  return http.request<ApiResponse<any>>("post", "/api/user/add", { data });
};

/** 获取用户端用户详情 (后端蓝图中没有明确的详情接口，但通常会有，这里暂时保留，如果实际不需要可删除) */
export const getClientUserDetail = (userId: number) => {
  return http.request<ApiResponse<any>>("get", `/api/user/${userId}`);
};

/** 更新用户端用户信息 */
export const updateClientUser = (userId: number, data: object) => {
  return http.request<ApiResponse<any>>("put", `/api/user/${userId}`, {
    data
  });
};

/** 删除用户端用户 */
export const deleteClientUser = (userId: number) => {
  return http.request<ApiResponse<any>>("delete", `/api/user/${userId}`);
};

/** 启用/禁用用户端用户 */
export const toggleClientUserStatus = (userId: number, data: { enable: number }) => {
  return http.request<ApiResponse<any>>("put", `/api/user/${userId}/status`, {
    data
  });
};

/** 重置用户端用户密码 */
export const resetClientUserPassword = (userId: number, data: { password: string }) => {
  return http.request<ApiResponse<any>>("put", `/api/user/${userId}/reset-password`, {
    data
  });
};

/** 绑定微信账号 */
